home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / comm / aprs30_2.zip / FILTRHST.BAS < prev    next >
BASIC Source File  |  1993-11-19  |  4KB  |  91 lines

  1. REM THIS PROGRAM CURRENTLY CONFIGURED TO BUILD A FILTERED TRACK HISTORY FILE
  2. REM FROM A NUMBER OF SOURCE HISTORY FILES.  THE FILTERING IS NOT AS IMPORTANT
  3. REM AS IT USED TO BE, BECAUSE NOW APRS PRE-FILTERS ALL POSITION REPORTS BEFORE
  4. REM EVEN SAVING THEM TO A TRACK HISTORY FILE.
  5. REM This original program was lost, and rebuilt from memory.  I havent really
  6. REM used it since I re entered it, so be prepared to have to twiddle it...
  7. REM
  8. REM It will filter out all position reports that are within a specified range
  9. REM of each other.  It is primarily used to eliminate all duplicate points
  10. REM while a station is stationary.  By making the range about .3 miles, almost
  11. REM all points from a boat in port including the errors of GPS selective
  12. REM availability will be eliminated.
  13. REM
  14. REM
  15. DIM P$(59), Num(39)
  16. LineP = 1: P$(1) = "NOTHING HERE TO START"
  17. REM ON ERROR GOTO ErrorTrap
  18.  
  19.     CLS
  20.     INPUT "Enter file name for accumulation of output if other than FILTROUT.HST"; F$
  21.     IF F$ = "" THEN F$ = "FILTROUT.HST"
  22.     OPEN F$ FOR OUTPUT AS #5
  23.     PRINT
  24.     INPUT "Enter range delta in miles if other than 0.3"; Del$
  25.     IF Del$ = "" THEN Del$ = ".3"
  26.  
  27. REM BEGIN HERE TO REPETITIVELY ASK FOR THE NEXT SOURCE FILE
  28. DO UNTIL UCASE$(a$) = "END"
  29. ReDo: CLS : LOCATE 1, 47: PRINT "NumLines", "NumGood"
  30.       LOCATE 3, 47: PRINT i, j
  31.       LOCATE 4, 1: PRINT "Units found in file"
  32.       LOCATE 6, 1: FOR ip = 1 TO LineP: PRINT LEFT$(P$(ip), 25), Num(ip): NEXT ip
  33.       LOCATE 1, 1
  34.       INPUT "Enter xxxxx.HST file name for filtering (or end)"; F$
  35.       IF UCASE$(F$) = "END" THEN EXIT DO
  36.       OPEN "b:" + F$ + ".hst" FOR INPUT AS #3
  37.       IF Fault = 53 THEN GOTO ReDo
  38.  
  39.    REM BEGIN HERE TO READ EVERY ENTRY IN THE xxxxx.HST FILE AND FILTER IT
  40.    DO WHILE NOT EOF(3)
  41.       LINE INPUT #3, a$
  42.       IF a$ <> "" THEN
  43.          PM = 0: i = i + 1
  44.          REM BUILD AN ARRAY OF ALL DIFFERENT STATIONS, SO THAT WE KEEP THE LATEST
  45.          REM POSIT OF EACH STATION FOR COMPARISON WITH EACH NEW POSIT IN THE FILE
  46.    
  47.          FOR ip = 1 TO LineP ' Identify which boat and add to array if new boat
  48.              IF LEFT$(a$, 9) = LEFT$(P$(ip), 9) THEN
  49.                 PM = ip: ip = LineP: Num(PM) = Num(PM) + 1
  50.                 END IF
  51.          NEXT ip: IF PM = 0 THEN LineP = LineP + 1: PM = LineP: Num(PM) = 1
  52.          REM Now compare new value with old value
  53.          IF ABS(VAL(MID$(a$, 26, 7)) - VAL(MID$(P$(PM), 26, 7))) > VAL(Del$) THEN
  54.             PRINT #5, a$: j = j + 1: P$(PM) = a$: LOCATE 3, 47: PRINT i, j
  55.          ELSEIF ABS(VAL(MID$(a$, 35, 8)) - VAL(MID$(P$(PM), 35, 8))) > VAL(Del$) THEN
  56.             PRINT #5, a$: j = j + 1: P$(PM) = a$: LOCATE 3, 47: PRINT i, j
  57.          END IF
  58.          REM the following line if activated assures that each new point is
  59.          REM always compared with the previous point no matter what it is...
  60.          REM In otherwords, the program works like a filter to remove adjacent
  61.          REM points that are closer than delta apart.
  62.          REM HOWEVER, if the following line is iimplemented in the above two
  63.          REM lines after each save, then the program operates like a step
  64.          REM filter throwing out all points EXCEPT for points separated by DEL
  65.          REM This results in an evenly spaced track history every DEL miles
  66.          REM P$(PM) = a$: LOCATE 3, 47: PRINT i, j
  67.       END IF
  68.    LOOP ' Loop back to read the next POSIT in this file
  69.    CLOSE 3
  70.  
  71. LOOP ' Loop back to beginning and ask for the next xxxx.HST file
  72. CLOSE 5: PRINT : PRINT "Filtered data from all files stored in FILTROUT.HST"
  73. INPUT "Hit return to conitinue..."; a$
  74. SYSTEM
  75.  
  76. ErrorTrap: Fault = ERR: LOCATE 2, 60'Error handling routine
  77.      ercntr = ercntr + 1: REM IF ercntr > 6 THEN INPUT "in err routine"; a$
  78.      IF ERR = 57 THEN PRINT "  I/O-error-User-"; : RESUME
  79.      IF ERR = 69 THEN PRINT "  Comm-buffer-overflow"; : RESUME
  80.      IF ERR = 53 THEN PRINT file$; "-NotFound": CLOSE #3: CLOSE #5: RESUME NEXT
  81.      IF ERR = 52 THEN PRINT file$; "-Bad#": CLOSE #3: CLOSE #5: RESUME NEXT
  82.      IF ERR = 64 THEN PRINT file$; "-BadName": CLOSE #3: CLOSE #5: RESUME NEXT
  83.      IF ERR = 62 THEN RESUME NEXT  'Read past end of file
  84.      IF ERR = 2 THEN PRINT "SYNTAX-error"
  85.      RESET: PRINT : PRINT "Error I cant fix. Number = "; ERR;
  86.      INPUT "Program crashed.  Sorry.  Hit RETURN to return to DOS"; a$
  87.      SYSTEM
  88.  
  89. END
  90.  
  91.